<?php
namespace Application\Model;

use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
use Zend\I18n\Validator;

class Product implements InputFilterAwareInterface
{

    public $id;

    public $name;

    public $desc;

    public $short_desc;

    public $price;

    public $code;

    public $category_id;

    public $video;

    public $banner;

    public $date_created;

    public $banner_type;

    public $banner_size;

    public $banner_name;

    public $product_file_type;

    public $product_file_size;

    public $product_file_name;

    protected $inputFilter;

    public function exchangeArray($data)
    {
        $this->id = (isset($data['id'])) ? $data['id'] : null;
        $this->name = (isset($data['name'])) ? $data['name'] : null;
        $this->desc = (isset($data['desc'])) ? $data['desc'] : null;
        $this->short_desc = (isset($data['short_desc'])) ? $data['short_desc'] : null;
        $this->price = (isset($data['price'])) ? $data['price'] : null;
        $this->code = (isset($data['code'])) ? $data['code'] : null;
        $this->category_id = (isset($data['category_id'])) ? $data['category_id'] : null;
        $this->video = (isset($data['video'])) ? $data['video'] : null;
        $this->banner = (isset($data['banner'])) ? $data['banner'] : null;
        $this->product_file = (isset($data['product_file'])) ? $data['product_file'] : null;
        $this->date_created = (isset($data['date_created'])) ? $data['date_created'] : null;

        $this->banner_type = (isset($data['banner_type'])) ? $data['banner_type'] : null;
        $this->banner_size = (isset($data['banner_size'])) ? $data['banner_size'] : null;
        $this->banner_name = (isset($data['banner_name'])) ? $data['banner_name'] : null;
        $this->product_file_type = (isset($data['product_file_type'])) ? $data['product_file_type'] : null;
        $this->product_file_size = (isset($data['product_file_size'])) ? $data['product_file_size'] : null;
        $this->product_file_name = (isset($data['product_file_name'])) ? $data['product_file_name'] : null;
    }

    public function getArrayCopy()
    {
        return get_object_vars($this);
    }

    public function setInputFilter(InputFilterInterface $inputFilter)
    {
        $this->inputFilter = $inputFilter;
        // throw new \Exception("Not used");
    }

    public function getInputFilter()
    {
        if (! $this->inputFilter) {
            $inputFilter = new InputFilter();
            $factory = new InputFactory();

            $inputFilter->add($factory->createInput(array(
                'name' => 'desc',
                'required' => true
            )));
            $this->inputFilter = $inputFilter;
        }

        return $this->inputFilter;
    }
}